package com.saber.pattern.factory;

/**
 * @author saber
 * @version 1.0
 * @Package: com.saber.pattern.factory
 * @Date: 2017/4/10
 * @Time: 11:08
 */
public class StaticFactoryMethod {

    public static Sender genSender(String which) throws BadRequestException {
        if (which.equalsIgnoreCase("email")) {
            return new EmailSender();
        } else if (which.equalsIgnoreCase("sms")) {
            return new SmsSender();
        } else {
            throw new BadRequestException("no type");
        }
    }

}
